from typing import *
from leetcode.editor.common.node import *


# leetcode submit region begin(Prohibit modification and deletion)
class Solution:
    def maximumUniqueSubarray(self, nums: List[int]) -> int:
        window = {}
        windsum = 0
        left = 0
        ans = 0
        for right,item in enumerate (nums):
            window[item] = window.get(item,0)+1
            windsum += item
            if window[item] == 1:
                ans = max(ans,windsum)
            while window[item]>1:
                l = nums[left]
                window[l]-=1
                windsum-=l
                left +=1
        return ans
# leetcode submit region end(Prohibit modification and deletion)


if __name__ == '__main__':
    solution = Solution()
    print(solution.maximumUniqueSubarray([187,470,25,436,538,809,441,167,477,110,275,133,666,345,411,459,490,266,987,965,429,166,809,340,467,318,125,165,809,610,31,585,970,306,42,189,169,743,78,810,70,382,367,490,787,670,476,278,775,673,299,19,893,817,971,458,409,886,434]))
    # your test code here